package cn.edu.zafu.bigdata.Wym;

public class Wym_Checkage {

    public static void main(String[] args){
        int age=18;

        try{
            checkage(age);
            System.out.println("年龄验证通过");
        }catch (InvalidAgeException e){
            System.out.println("错误："+e.getMessage());
        }
    }

    public static void checkage(int age) throws InvalidAgeException {
        if(age<18){
            throw new InvalidAgeException("年龄至少为18岁");
        }
        return;
    }

}

class InvalidAgeException extends Exception{
    public InvalidAgeException(String a){
        super(a);//super用来引用父类的变量、方法和构造函数；
    }
}